package org.mantenimientojsf.generales ;

import java.io.Serializable;
import java.util.List;
import java.util.Locale;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.model.SelectItem;
import javax.annotation.ManagedBean;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
/**
*
* @author avbravo
*/

@ManagedBean
@SessionScoped
@Named(value = "idiomas")
public class Idiomas implements Serializable {
private static final long serialVersionUID = 1L;
public Idiomas() {
}

private static String locale = Locale.getDefault().getDisplayLanguage();
public void setLocale(String locale) {
      this.locale = locale;
  }

  public synchronized String getLocale() {
      return locale;
    }

public synchronized String changeLanguage() {
  return "changed";
    }

public String englishAction() {
   FacesContext context = FacesContext.getCurrentInstance();
   context.getViewRoot().setLocale(Locale.ENGLISH);
   this.locale = "en";
   return null;
}
public String spanishAction() {
  FacesContext context = FacesContext.getCurrentInstance();
  context.getViewRoot().setLocale(new Locale("es"));
   this.locale = "es";
  return null;
}


}
